package com.ruoyi.product.enums;

import cn.hutool.core.util.ObjectUtil;
import lombok.Getter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Getter
public enum ProdPriceEnum {

    UV(1, "UV计价"),
    REG(2, "注册计价"),
    UNION(3, "联登计价"),
    ;

    Integer value;
    String name;

    ProdPriceEnum(Integer value, String name){
        this.value = value;
        this.name = name;
    }

    public static String getNameByValue(Integer value){
        for (ProdPriceEnum item : values()) {
            if (ObjectUtil.equals(value, item.getValue())){
                return item.getName();
            }
        }
        return value+"";
    }

    public static List<Map<String, Object>> getListMap() {
        List<Map<String, Object>> listMap = new ArrayList<>();
        for (ProdPriceEnum item : values()) {
            Map<String, Object> itemMap = new HashMap<>();
            itemMap.put("name", item.getName());
            itemMap.put("value", item.getValue());
            listMap.add(itemMap);
        }
        return listMap;
    }


}